package com.chinasofti.shoot;

import java.util.Random;

//小蜜蜂 既是飞行物  也是奖励
public class Bee extends FlyingObject implements Award{

    private int xSpeed = 1;//x坐标的步数
    private int ySpeed = 2;//y坐标的步数
    private int awardType; //奖励的类型

    public Bee(){
        image = ShootGame.bee;
        width = image.getWidth();
        height = image.getHeight();
        Random rand = new Random();
        x = rand.nextInt(ShootGame.WIDTH - this.width);
        y = -this.height;
        //y = 200;
        awardType = rand.nextInt(2);
    }

    @Override
    public int getType() {
        return awardType;
    }

    @Override
    public void step() {
        x += xSpeed;
        y += ySpeed;
        if(x >ShootGame.WIDTH - this.width){//最右边
            xSpeed = -1;//向左
        }
        if(x<0){//最左边了
            xSpeed = 1;//向右
        }
    }
    //判断蜜蜂是否越界
    @Override
    public boolean outOfBounds() {
        return this.y > ShootGame.HEIGHT;
    }
}
